package es.xpt.ysf.commons.location.model;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlTransient;

import es.xpt.ysf.model.Item;
import es.xpt.ysf.model.TagMap;

/**
 * Represents a country.
 * 
 * @author joseignacio.garces@xplayat.es
 * @version YSF 1.0
 */
@SuppressWarnings("serial")
@XmlAccessorType(XmlAccessType.FIELD)
public class Country extends Item {

	/**
	 * Tags used to mark internal state and/or behaviour.
	 */
	@XmlTransient
	private TagMap tags;
	@XmlTransient
	private String iso2;
	@XmlTransient
	private String iso3;
	@XmlTransient
	private String isoNum;
	
	
	public Country() {

	}

	/**
	 * Constructor of this class with appropriate parameters. Initializes the
	 * values of instance variables with appropriate values.
	 * 
	 * @param description
	 * @param localizacion
	 * @param codigo
	 */
	public Country(String code, String description) {
		super(code, description);
	}

	/**
	 * This method checks not null fields declared in YSF_CB_PAIS table.
	 * 
	 * @return true if all not null fields have a value
	 */
	public boolean checkRequired() {
		if (getDescription() == null)
			return false;
		if (getCode() == null)
			return false;
		return true;
	}

	/**
	 * This method checks the primary keys fields.
	 * 
	 * @return true if all fields in the primary Key have a value
	 */
	public boolean checkPrimaryKey() {
		if (getCode() == null)
			return false;
		return true;
	}

	/**
	 * This method validates the object values
	 * 
	 * @return true if everything is ok
	 */
	public boolean validateData() {
		if (getDescription().length() > 240)
			return false;
		if (getCode() != null && getCode().length() > 50)
			return false;
		return true;
	}

	/**
	 * Clone will return identical deep copy of this valueObject. Note, that
	 * this method is different than the clone() which is defined in
	 * java.lang.Object. Here, the retuned cloned object will also have all its
	 * attributes cloned.
	 * 
	 * @return the cloned object
	 * @throws CloneNotSupportedException 
	 */
	public Object clone() throws CloneNotSupportedException {
		Country cloned = (Country)super.clone();
		cloned.setTags(tags);
		return cloned;
	}

	/**
	 * @return the tags
	 */
	public TagMap getTags() {
		return tags;
	}

	/**
	 * @param tags
	 *            the tags to set
	 */
	public void setTags(TagMap tags) {
		this.tags = tags;
	}

	/**
	 * toString will return String object representing the state of this
	 * valueObject. This is useful during application development, and possibly
	 * when application is writing object states in textlog.
	 */
	public String toString() {
		StringBuffer ret = new StringBuffer();
		ret.append(this.getClass().getName() + " :\n");
		ret.append("description='" + getDescription() + "'\n");
		ret.append("code='" + getCode() + "'\n");
		ret.append("locale='" + getLocale() + "'\n");
		ret.append("tags='" + getTags() + "'\n");
		return ret.toString();
	}

	/**
	 * @return the iso2
	 */
	public String getIso2() {
		return iso2;
	}

	/**
	 * @param iso2 the iso2 to set
	 */
	public void setIso2(String iso2) {
		this.iso2 = iso2;
	}

	/**
	 * @return the iso3
	 */
	public String getIso3() {
		return iso3;
	}

	/**
	 * @param iso3 the iso3 to set
	 */
	public void setIso3(String iso3) {
		this.iso3 = iso3;
	}

	/**
	 * @return the isoNum
	 */
	public String getIsoNum() {
		return isoNum;
	}

	/**
	 * @param isoNum the isoNum to set
	 */
	public void setIsoNum(String isoNum) {
		this.isoNum = isoNum;
	}

}

// This file has been generated by Logic Generator v1.0
